﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>添加用户</title>
    <link href="~/lib/layui/css/layui.css" rel="stylesheet" />
    <script src="~/lib/layui/layui.js"></script>
</head>
<body>
    <form class="layui-form" action="/Customer/Add" id="Addfm" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-inline">
                <input type="text" name="CustomerName" required lay-verify="required" value="" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input type="text" name="CustomerPhone" required lay-verify="required" value="" placeholder="请输入手机号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-inline">
                <input type="text" name="CustomerNiCheng" required lay-verify="required" value="" placeholder="请输入昵称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-inline">
               男 <input type="radio" name="CustomerSex" required lay-verify="required" value="男" checked autocomplete="off" class="layui-input">
               女 <input type="radio" name="CustomerSex" required lay-verify="required" value="女" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            form.on('submit(formDemo)', function (data) {
                var str = $("#Addfm").serialize();
                $.post("/Customer/Add", str, function(res) {
                    if (res.success) {
                        layer.msg("添加成功", function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            //修改成功后刷新父界面
                            window.parent.location.reload();
                        });
                    }
                    else {
                        layer.alert("添加失败:" + res.message, { icon: 5 });
                    }
                }, "json");
                return false;
            });
        });
        </script>
</body>
</html>
